/**
 * Created by way on 16/9/21.
 */

import cfg from '../config';
import Router from '../lib/krouter';
import {sid, tab, mobile, get, post, getUser, docker} from '../util/api';
import {jumpUrl} from '../util/aid';

// js
import Home from './home';
import Sign from './sign';

const router = new Router({
  container: '#dvContainer',
});

const user = {"_id": "597729cb60931830a08b153f", "name": "喻华峰", "mobile": "18605812888", "phone": "", "depart": "大客户服务中心", "branch": "南岸", "shop": "南岸", "shopNo": "888", "pid": "81195892", "__v": 0, "addTime": "2017-07-25T11:21:47.287Z", "role": ["座席"], "perm": [11], "skill": [], "subed": {"pic": [], "msg": [], "all": [], "sta": []}, "sub": {"pic": [], "msg": [], "all": [], "sta": []}, "member": [], "group": [], "contact": [], "friend": [], "tag": [], "openid": []};

document.ready(() => {
  router
    .push(new Sign())
    .push(new Home());

  sid('11');
  tab('1');
  docker('rel');

  // mobile('18605812888');

  // router.go('./lottery/home', {user: user}, true);
  //
  if (mobile()) {
    getUser(`${HOST_URL}${cfg.ogs.userInfo}`, '', (rs) => {
      if (rs) {
        console.log('getUser [rs] ', rs);
        mobile(rs.mobile);
        router.go('/ogspc/home', {user: rs}, true);
      } else {
        router.go('/ogspc/sign', '', true);
      }
    });
  } else {
    router.go('/ogspc/sign', '', true);
  }
});